// import { formCache } from './cache'

// const DRAWING_ITEMS = 'drawingItems'
// const DRAWING_ITEMS_VERSION = '1.2'
// const DRAWING_ITEMS_VERSION_KEY = 'DRAWING_ITEMS_VERSION'
const DRAWING_ID = 'idGlobal'
const TREE_NODE_ID = 'treeNodeId'
// const FORM_CONF = 'formConf'

export async function getDrawingList() {
	// // 加入缓存版本的概念，保证缓存数据与程序匹配
	// const version = formCache.getItem(DRAWING_ITEMS_VERSION_KEY)
	// if (version !== DRAWING_ITEMS_VERSION) {
	// 	formCache.setItem(DRAWING_ITEMS_VERSION_KEY, DRAWING_ITEMS_VERSION)
	// 	saveDrawingList([])
	// 	return null
	// }
	// if (!id) return null
	// const str = await formCache.getItem(`${DRAWING_ITEMS}-${id}`)
	// if (str) return JSON.parse(str)
	return null
}

export function saveDrawingList() {
	// formCache.setItem(`${DRAWING_ITEMS}-${id}`, JSON.stringify(list))
}

export function getIdGlobal() {
	const str = localStorage.getItem(DRAWING_ID)
	if (str) return parseInt(str, 10)
	return 100
}

export function saveIdGlobal(id) {
	localStorage.setItem(DRAWING_ID, `${id}`)
}

export function getTreeNodeId() {
	const str = localStorage.getItem(TREE_NODE_ID)
	if (str) return parseInt(str, 10)
	return 100
}

export function saveTreeNodeId(id) {
	localStorage.setItem(TREE_NODE_ID, `${id}`)
}

export async function getFormConf() {
	// const str = await formCache.getItem(`${FORM_CONF}-${id}`)
	// // console.log(str, 1111)
	// if (str) return JSON.parse(str)
	return null
}

export function saveFormConf() {
	// formCache.setItem(`${FORM_CONF}-${id}`, JSON.stringify(obj))
}
